In [1]:
import numpy as np
import igraph as ig
import graph_qa as qa
import cPickle as pickle
In [2]:
graph = ig.Graph.Read_GraphML('drugbank-ext-v2.grahpml')
The 'settings' used throughout this experiment
The four multiple choice answers are all medicines that are all present in Drugbank.
They can be found using qa.find_drugbank_entity
. The question text, on the other hand, does not contain entities in Drugbank. However, some entities might have entities from the question text in their description. So we try to identify relevant drugbank entities by doing a full-text search over drugbank (using Virtuoso's built-in Precision Search). Clearly, this representation is not perfect: if we select only a few entities, which are actually unrelated, a good result seems implausible. So we examine this: what is the (very rough) effect of the number of entities we pick from the ranked full-text search results?
In [3]:
def perform_experiment_3(setup,
trials=[2,5,10,15,20,25,50,75,100,200,400,700,1000,1500]):
"""Performs experiment 3
"""
setup['description'] = """
The four multiple choice answers are all medicines that are all present in Drugbank.
They can be found using `qa.find_drugbank_entity`.
The question text, on the other hand, does not contain entities in Drugbank.
However, some entities might have entities from the question text in their description.
So we try to identify relevant drugbank entities by doing a full-text search over drugbank
(using Virtuoso's built-in Precision Search).
Clearly, this representation is not perfect: if we select only a few entities,
which are actually unrelated, a good result seems implausible.
So we examine this: **what is the (very rough) effect of the number of
entities we pick from the ranked full-text search results?**
"""
setup['settings'] = 'Degree-based weights and average-median qa weights'
setup['graph'] = 'drugbank-ext-v2.graphml'
q_entities_list = []
for search_query in setup['q_text_entities']:
res = qa.search_entities(search_query, None)
q_entities_list.append(res)
ans_entities=[]
for ans in setup['ans_text_entities']:
if ans[0][0] != '<':
ans_entities.append(map(qa.find_drugbank_entity, ans))
else:
ans_entities.append(ans)
experiment = []
for n in trials:
result = {'n': n}
q_entities = []
for qlist in q_entities_list:
q_entities += qlist[0:n]
output = qa.rank_qa(graph, q_entities, ans_entities)
print 'n: '+ str(n) +' '+str(output)
result['output'] = output
result['q_len'] = len(q_entities)
result['q_entities'] = q_entities
experiment.append(result)
setup['results'] = experiment
return setup
Synthetic analog of deoxyadenosine; active triphosphate form inhibits viral replication by competitively inhibiting HIV reverse transcriptase and by chain termination ;may be prescribed concurrently with zidovudine or given as monotherapy; major clinical toxicity is a dose-dependent pancreatitis.
- zalcitabine (Hivid, ddc)
- trifluridine (Viroptic)
- didanosine (Videx, ddI)
- foscarnet (Foscavir)
Correct answer: 3 (didanosine)
In [31]:
setup_q2 = {
'date': '2014/07/16 01:40',
'qid': 'Q119#2',
'correct': 2,
'q_text_entities': [
'deoxyadenosine','active triphosphate','viral replication',
'HIV reverse transcriptase','chain termination','zidovudine',
'monotherapy','dose-dependent pancreatitis'],
'ans_text_entities': [
['zalcitabine'],
['trifluridine'],
['didanosine'],
['foscarnet']]
}
exp3_q2 = perform_experiment_3(setup_q2)
pickle.dump(exp3_q2, open('qa-experiment3-q2.p','w'))
A patient is being treated with digoxin for congestive heart failure. To enhance inotropic effects, the dosage was increased. Soon afterwards, the patient complained of dizziness, fatigue, and disturbances in color vision. An ECG was taken and exhibit arrhythmias consistent with digitialis intoxication. What antiarrhythmic drugs might be used to treat worsening ventricular arrhythmias with hemodynamic compromise?
- amiodarone (Cordarone)
- lidocaine (Xylocaine)
- adenosine (Adenocard)
- propranolol (Inderal)
Correct: 2 (lidocaine)
In [38]:
setup_q3 = {
'date': '2014/07/16 02:02',
'qid': 'Q34#18',
'correct': 1,
'q_text_entities': [
'digoxin','congestive heart failur','inotropic effects',
'dizziness','fatigue','color vision','ECG','arrhythmias',
'digitalis intoxication','antiarrhythmic','ventricular arrhythmias','hemodynamic compromise'],
'ans_text_entities': [
['amiodarone'],
['lidocaine'],
['adenosine'],
['propranolol']]
}
exp3_q3 = perform_experiment_3(setup_q3)
pickle.dump(exp3_q3, open('qa-experiment3-q3.p','w'))
A patient is admitted for treatment of myocardial infarction. During a prolonged recovery period, the patient experienced episodes of ventricular tachycardia. Following discharge from hospital, the patient was instructed to take a drug to prevent recurrence of ventricular tachycardia. After a few days, the patient complained of dizziness and then lost consciousness. Upon admission to the hospital, the patient was found to be somewhat hypokalemic. A diagnosis of Torsades de Pointes was made. A test to determine the blood level of the antiarrhythmic reveal the drug was present in a slightly subtherapeutic level. What was the drug?
- sotalol (Betapace)
- procainamide (Procan SR, Pronestyl-SR)
- quinidine gluconate (Quinaglute, Quinalan)
- lidocaine (Xylocaine)
Correct: 3 (quinidine)
In [42]:
setup_q4 = {
'date': '2014/07/16 02:24',
'qid': 'Q16#34',
'correct': 2,
'q_text_entities': [
'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
'hypokalemic','Torsades de Pointes','antiarrhythmic'],
'ans_text_entities': [
['sotalol'],
['procainamide'],
['<http://bio2rdf.org/drugbank_resource:bc2c80c68b00a7bc37b5afd1857d8b21>'], # quinedine gluconate (guinedine is also present)
['lidocaine']]
}
exp3_q4 = perform_experiment_3(setup_q4)
pickle.dump(exp3_q4, open('qa-experiment3-q4.p','w'))
In [44]:
setup_q4b = {
'date': '2014/07/16 02:34',
'qid': 'Q16#34',
'correct': 2,
'comments': """
Uses a different representation of answer 3 then in experiment3-q4.
Here both 'quined%%!ine' and 'quinedine gluconate' are activated.
""",
'q_text_entities': [
'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
'hypokalemic','Torsades de Pointes','antiarrhythmic'],
'ans_text_entities': [
['sotalol'],
['procainamide'],
['<http://bio2rdf.org/drugbank:DB00908>',# both quinedine and quinedine gluconate
'<http://bio2rdf.org/drugbank_resource:bc2c80c68b00a7bc37b5afd1857d8b21>'],
['lidocaine']]
}
exp3_q4b = perform_experiment_3(setup_q4b)
pickle.dump(exp3_q4b, open('qa-experiment3-q4b.p','w'))
In [45]:
setup_q4c = {
'date': '2014/07/16 02:34',
'qid': 'Q16#34',
'correct': 2,
'comments': """
Uses a different representation of answer 3 then in experiment3-q4
and experiment3-q4b. Here only quinedine is activated.
""",
'q_text_entities': [
'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
'hypokalemic','Torsades de Pointes','antiarrhythmic'],
'ans_text_entities': [
['sotalol'],
['procainamide'],
['<http://bio2rdf.org/drugbank:DB00908>'], # quinedine
['lidocaine']]
}
exp3_q4c = perform_experiment_3(setup_q4c)
pickle.dump(exp3_q4c, open('qa-experiment3-q4c.p','w'))
An elderly male patient has essential hypertension, congestive heart failure, and type I insulin-dependent diabetes. His congestive failure developed secondary to coronary vascular disease associated with hyperlipidemia. What antihypertensive drug(s) may be most appropriate for this patient?
- chlorothiazide (Diuril)
- captopril (Capoten)
- propranolol (Inderal)
- metoprolol (Lopressor)
Correct: 2 (captopril)
In [47]:
setup_q5 = {
'date': '2014/07/16 02:14',
'qid': 'Q26#11',
'correct': 1,
'q_text_entities': [
'essential hypertension','hypertension','congestive heart failure',
'type i diabetes', 'insulin-dependent','diabetes',
'coronary vascular disease','hyperlipidemia','antihypertensive'
],
'ans_text_entities': [
['chlorothiazide'],
['captopril'],
['propranolol'],
['metoprolol']]
}
exp3_q5 = perform_experiment_3(setup_q5)
pickle.dump(exp3_q5, open('qa-experiment3-q5.p','w'))
Mainly eliminated by renal mechanisms as the hypoxanthine metabolite, this antiviral agent is effective for treating acute keratoconjunctivitis (ointment) and HSV encephalitis (i.v.)
- vidarabine (Vira-A)
- ganciclovir (DHPG, Cytovene)
- foscarnet (Foscavir)
- zidovudine (Retrovir, AZT, azidothymidine)
Correct: 1 (vidarabine)
In [48]:
setup_q6 = {
'date': '2014/07/16 02:47',
'qid': 'Q121#5',
'correct': 0,
'q_text_entities': [
'renal mechanisms', 'hypoxanthine metabolite','antiviral agent',
'keratoconjunctivitis', 'HSV','encephalitis' # with and without ointment?
'coronary vascular disease','hyperlipidemia','antihypertensive'
],
'ans_text_entities': [
['chlorothiazide'],
['captopril'],
['propranolol'],
['<http://bio2rdf.org/drugbank_resource:4ae6628acf456f373bb1241494313680>',
'<http://bio2rdf.org/wikipedia:Zidovudine>']]
}
exp3_q6 = perform_experiment_3(setup_q6)
pickle.dump(exp3_q6, open('qa-experiment3-q6.p','w'))
In [49]:
setup_q6b = {
'date': '2014/07/16 02:47',
'qid': 'Q121#5',
'correct': 0,
'comment': 'Different representation of question: added "ointment"',
'q_text_entities': [
'renal mechanisms', 'hypoxanthine metabolite','antiviral agent',
'keratoconjunctivitis', 'HSV','encephalitis', 'ointment',
'coronary vascular disease','hyperlipidemia','antihypertensive'
],
'ans_text_entities': [
['chlorothiazide'],
['captopril'],
['propranolol'],
['<http://bio2rdf.org/drugbank_resource:4ae6628acf456f373bb1241494313680>',
'<http://bio2rdf.org/wikipedia:Zidovudine>']]
}
exp3_q6b = perform_experiment_3(setup_q6b)
pickle.dump(exp3_q6b, open('qa-experiment3-q6b.p','w'))
In [50]:
setup_q7 = {
'date': '2014/07/16 03:03',
'qid': 'Q16#34 and Q119#2',
'correct': None,
'comments': """
Merging the question of Question 4 and the anser from question 2. The question
being: is there a difference in the rough distance?
""",
'q_text_entities': [
'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
'hypokalemic','Torsades de Pointes','antiarrhythmic'],
'ans_text_entities': [
['zalcitabine'],
['trifluridine'],
['didanosine'],
['foscarnet']]
}
exp3_q7 = perform_experiment_3(setup_q7)
pickle.dump(exp3_q7, open('qa-experiment3-q7.p','w'))
A patient with Type I diabetes presents with significant water retention and pulmonary congestion. Serum creatinine, BUN and potassium were significantly elevated. The diagnosis was advanced renal failure. A diuretic was given to treat water retention, but shortly thereafter the patient exhibited cardiac conduction changes which progressed to heart block and cardiac arrest. The diuretic which was determined to cause this event was probably:
- furosemide (Lasix)
- triamterene (Dyrenium)
- chlorothiazide (Diuril)
- bumetanide (Bumex)
Correct answer: 2 (Triamrene)
In [4]:
setup_q1b = {
'date': '2014/07/16 12:09',
'qid': 'Q83#4',
'correct': 2,
'comments': """
Repeating experiment for question 1
""",
'q_text_entities': [
'diabetes', 'water retention','pulmonary congestion',
'Serum creatinine','BUN','potassium', 'renal failure',
'cardiac conduction','heart block','carciac arrest'],
'ans_text_entities': [
['furosemide'],
['triamterene'],
['chlorothiazide'],
['bumetanide']]
}
exp3_q1b = perform_experiment_3(setup_q1b)
pickle.dump(exp3_q1b, open('qa-experiment3-q1b.p','w'))
In [8]:
%%time
setup_q1c = {
'date': '2014/07/16 14:00',
'qid': 'Q83#4',
'correct': 2,
'comments': "Question 1 but with more measurements",
'q_text_entities': [
'diabetes', 'water retention','pulmonary congestion',
'Serum creatinine','BUN','potassium', 'renal failure',
'cardiac conduction','heart block','carciac arrest'],
'ans_text_entities': [
['furosemide'],
['triamterene'],
['chlorothiazide'],
['bumetanide']]
}
# Can add at most 1349 question nodes
exp3_q1c = perform_experiment_3(setup_q1c,range(5,500,5))
pickle.dump(exp3_q1c, open('qa-experiment3-q1c.p','w'))
In [ ]: